﻿using CQRSFramework.Commands;
using CQRSFramework.Domains;
using CQRSFramework.Test.commands;
using CQRSFramework.Test.domain;

namespace CQRSFramework.Test.commandhandler
{
    public class AccountCommandHandler : ICommandHandler<CreateAccountCommand>,
        ICommandHandler<ChangeAccountNameCommand>
    {
        public void Handle(ICommandContext context, CreateAccountCommand command)
        {
            context.Add(new AccountAggregate(command.AggregateRootId, command.UserId, command.Name));
        }
        public void Handle(ICommandContext context, ChangeAccountNameCommand command)
        {
            context.Get<AccountAggregate>(command.AggregateRootId).ChangeName(command.Name, command.UserId);
        }
    }
}
